package com.ruoyi.web.controller.interfaceConfig.businessObject;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.interfaceConfig.businessObject.domain.vo.BusinessObjectConfigVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.interfaceConfig.businessObject.domain.BusinessObjectConfig;
import com.ruoyi.interfaceConfig.businessObject.service.IBusinessObjectConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务对象配置Controller
 * 
 * @author YiYuan
 * @date 2024-02-01
 */
@RestController
@RequestMapping("/interfaceConfig/businessObject")
public class BusinessObjectConfigController extends BaseController
{
    @Autowired
    private IBusinessObjectConfigService businessObjectConfigService;

    /**
     * 查询业务对象配置列表
     */
    @PreAuthorize("@ss.hasPermi('interfaceConfig:businessObject:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessObjectConfig businessObjectConfig)
    {
        startPage();
        List<BusinessObjectConfig> list = businessObjectConfigService.selectBusinessObjectConfigList(businessObjectConfig);
        return getDataTable(list);
    }

    /**
     * 导出业务对象配置列表
     */
    @PreAuthorize("@ss.hasPermi('interfaceConfig:businessObject:export')")
    @Log(title = "业务对象配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinessObjectConfig businessObjectConfig)
    {
        List<BusinessObjectConfig> list = businessObjectConfigService.selectBusinessObjectConfigList(businessObjectConfig);
        ExcelUtil<BusinessObjectConfig> util = new ExcelUtil<BusinessObjectConfig>(BusinessObjectConfig.class);
        util.exportExcel(response, list, "业务对象配置数据");
    }

    /**
     * 获取业务对象配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('interfaceConfig:businessObject:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(businessObjectConfigService.selectBusinessObjectConfigById(id));
    }

    /**
     * 新增业务对象配置
     */
    @PreAuthorize("@ss.hasPermi('interfaceConfig:businessObject:add')")
    @Log(title = "业务对象配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessObjectConfigVo businessObjectConfigVo)
    {
        return toAjax(businessObjectConfigService.insertBusinessObjectConfig(businessObjectConfigVo));
    }

    /**
     * 修改业务对象配置
     */
    @PreAuthorize("@ss.hasPermi('interfaceConfig:businessObject:edit')")
    @Log(title = "业务对象配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessObjectConfigVo businessObjectConfigVo)
    {
        return toAjax(businessObjectConfigService.updateBusinessObjectConfig(businessObjectConfigVo));
    }

    /**
     * 删除业务对象配置
     */
    @PreAuthorize("@ss.hasPermi('interfaceConfig:businessObject:remove')")
    @Log(title = "业务对象配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(businessObjectConfigService.deleteBusinessObjectConfigByIds(ids));
    }

    @GetMapping("/getSourceAndTargetSysObject")
    public AjaxResult getSourceAndTargetSysObject() {
        return businessObjectConfigService.getSourceAndTargetSysObject();
    }
}
